<?php

/**
 * Mesure form base class.
 *
 * @method Mesure getObject() Returns the current form's model object
 *
 * @package    appcemhti
 * @subpackage form
 * @author     Steve Cancès
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseMesureForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_mesure'         => new sfWidgetFormInputHidden(),
      'id_echantillon'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Echantillon'), 'add_empty' => false)),
      'id_lieu'           => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Lieu'), 'add_empty' => true)),
      'id_methode_mesure' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('MethodeMesure'), 'add_empty' => false)),
      'id_traitement'     => new sfWidgetFormInputText(),
      'ok'                => new sfWidgetFormInputText(),
      'date_mesure'       => new sfWidgetFormDateTime(),
      'fichiernt'         => new sfWidgetFormInputText(),
      'fichiert'          => new sfWidgetFormInputText(),
      'created_at'        => new sfWidgetFormDateTime(),
      'updated_at'        => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id_mesure'         => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_mesure')), 'empty_value' => $this->getObject()->get('id_mesure'), 'required' => false)),
      'id_echantillon'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Echantillon'))),
      'id_lieu'           => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Lieu'), 'required' => false)),
      'id_methode_mesure' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('MethodeMesure'))),
      'id_traitement'     => new sfValidatorInteger(array('required' => false)),
      'ok'                => new sfValidatorInteger(array('required' => false)),
      'date_mesure'       => new sfValidatorDateTime(array('required' => false)),
      'fichiernt'         => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'fichiert'          => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'created_at'        => new sfValidatorDateTime(array('required' => false)),
      'updated_at'        => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('mesure[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Mesure';
  }

}
